package application.model 
{
	import application.ApplicationFacade;
	import application.model.VO.ModuleNavVO;
	import application.model.VO.ModuleNavItemVO;
	import org.puremvc.as3.interfaces.IProxy;
	import org.puremvc.as3.patterns.proxy.Proxy;
	/**
	 * ...
	 * @author Ning
	 */
	public class ModuleNavProxy extends Proxy implements IProxy
	{
		public static const NAME:String = 'ModuleNavProxy';
		private var _layoutProxy:LayoutProxy;
		private var _names:Array;
		public function get names():Array {
			return _names;
		}
		public function ModuleNavProxy() 
		{
			super(NAME, new ModuleNavVO);
			init();
		}
		private function init():void
		{
			_names = [];
			_layoutProxy = facade.retrieveProxy(LayoutProxy.NAME) as LayoutProxy;
		}
		public function setConfig():void
		{
			var arr:Array = [];
			var moduleXML:XMLList = AppGlobal.CONFIG_XML.modules;
			for (var i:int = 0; i < moduleXML.module.length(); i++ )
			{
				var moduleVO:ModuleNavItemVO = new ModuleNavItemVO;
				moduleVO.name = String(moduleXML.module[i].@['name']);
				moduleVO.buttonUIKey = String(moduleXML.module[i].@['buttonUIKey']);
				arr.push(moduleVO);
				_names.push(moduleVO.name);
			}
			moduleNavData.modules = arr;
			moduleNavData.layout = _layoutProxy.getLayout(AppGlobal.MAIN_NAV_LAYOUT_KEY);
			moduleNavData.hgap = Number(AppGlobal.CONFIG_XML.modules.@['hGap']);
			
			sendNotification(ApplicationFacade.UPDATE_MODULE_NAV_DATA, moduleNavData);
		}
		private function get moduleNavData():ModuleNavVO
		{
			return data as ModuleNavVO;
		}
	}
}